home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Warrior’s Progress / source code / Source / Libraries / Drawing / GrafPortObject.h < prev    next >
Encoding:
Text File  |  1997-06-28  |  3.6 KB  |  112 lines  |  [TEXT/CWIE]

  1. // GrafPortObject.h
  2.  
  3. #ifndef GrafPortObject_h
  4. #define GrafPortObject_h
  5.  
  6. #ifndef Rectangle_h
  7. #include "Rectangle.h"
  8. #endif
  9. #ifndef FontNumber_h
  10. #include "FontNumber.h"
  11. #endif
  12. #ifndef FontSize_h
  13. #include "FontSize.h"
  14. #endif
  15. #ifndef SourceMode_h
  16. #include "SourceMode.h"
  17. #endif
  18. #ifndef PatternMode_h
  19. #include "PatternMode.h"
  20. #endif
  21. #ifndef Face_h
  22. #include "Face.h"
  23. #endif
  24.  
  25. class GrafPortObject: public GrafPort
  26.   {
  27.     private:
  28.         // not implemented:
  29.             GrafPortObject( const GrafPortObject& );
  30.             void operator=( const GrafPortObject& );
  31.  
  32.         CGrafPort& UncheckedColorCast()
  33.             { return *reinterpret_cast<CGrafPort*>( this ); }
  34.  
  35.         const CGrafPort& UncheckedColorCast() const
  36.             { return *reinterpret_cast<const CGrafPort*>( this ); }
  37.     
  38.     public:
  39.         GrafPortObject();
  40.         ~GrafPortObject();
  41.         
  42.         static GrafPortObject& Current()                    { return static_cast<GrafPortObject&>( *qd.thePort ); }
  43.         bool IsCurrent() const                                { return this == &Current(); }
  44.         void BeCurrent()                                        { SetPort( this ); }
  45.         
  46.         bool InColor() const                                    { return (portBits.rowBytes & 0x8000) != 0; }
  47.         
  48.         CGrafPort& ColorCast()                                { Assert( InColor() ); return UncheckedColorCast(); }
  49.         const CGrafPort& ColorCast() const                { Assert( InColor() ); return UncheckedColorCast(); }
  50.         
  51.         Rectangle LocalBitMapBounds() const;
  52.         
  53.         Rectangle LocalBounds() const                        { return portRect; }
  54.         Rectangle GlobalBounds() const;
  55.         
  56.         PointObject LocalToGlobal() const;
  57.         PointObject GlobalToLocal() const;
  58.         
  59.         RgnHandle VisibleRegion() const                    { return visRgn; }
  60.         
  61.         const Pattern& BackgroundPattern() const        { return bkPat; }
  62.         const Pattern& FillPattern() const                { return fillPat; }
  63.  
  64.  
  65.         void SetPenPosition( PointObject p )            { Assert( IsCurrent() ); MoveTo( p.h, p.v ); }
  66.         PointObject PenPosition() const                    { return pnLoc; }
  67.  
  68.         void SetPenSize( PointObject p )                    { Assert( IsCurrent() ); ::PenSize( p.h, p.v ); }
  69.         PointObject PenSize() const                        { return pnSize; }
  70.         
  71.         void SetPenMode( PatternMode mode )                { Assert( IsCurrent() ); ::PenMode( mode.Value() ); }
  72.         PatternMode PenMode() const                        { return PatternMode::Make( pnMode ); }
  73.  
  74.         void SetPenPattern( const ::Pattern& p )        { Assert( IsCurrent() ); PenPat( &p ); }
  75.         const Pattern& PenPattern() const                { return pnPat; }
  76.  
  77.         void HidePen()                                            { Assert( IsCurrent() ); ::HidePen(); }
  78.         void ShowPen()                                            { Assert( IsCurrent() ); ::ShowPen(); }
  79.         bool PenVisible() const                                { return pnVis >= 0; }
  80.         int16 PenHidingLevel() const                        { return -pnVis; }
  81.  
  82.         RGBColor ForegroundColor() const;
  83.         void SetForegroundColor( const RGBColor& c )    { Assert( IsCurrent() ); RGBForeColor( &c ); }
  84.  
  85.         RGBColor BackgroundColor() const;
  86.         void SetBackgroundColor( const RGBColor& c )    { Assert( IsCurrent() ); RGBBackColor( &c ); }
  87.         
  88.         
  89.         void SetFont( FontNumber font )                    { Assert( IsCurrent() ); TextFont( font.Value() ); }
  90.         FontNumber Font() const                                { return FontNumber::Make( txFont ); }
  91.  
  92.         void SetTextSize( FontSize size )                { Assert( IsCurrent() ); ::TextSize( size.Value() ); }
  93.         FontSize TextSize() const                            { return FontSize::Make( txSize ); }
  94.  
  95.         void SetStyle( ::Style style )                    { Assert( IsCurrent() ); TextFace( style ); }
  96.         ::Style Style() const                                { return txFace; }
  97.  
  98.         void SetFace( const ::Face& );
  99.         ::Face Face() const;
  100.         
  101.         void SetTextMode( SourceMode mode )                { Assert( IsCurrent() ); ::TextMode( mode.Value() ); }
  102.         SourceMode TextMode() const                        { return SourceMode::Make( txMode ); }
  103.  
  104.         void SetSpaceStretch( Fixed stretch )            { Assert( IsCurrent() ); SpaceExtra( stretch ); }
  105.         Fixed SpaceStretch() const                            { return spExtra; }
  106.  
  107.         void SetCharacterStretch( Fixed stretch );
  108.         Fixed CharacterStretch() const;
  109.   };
  110.  
  111. #endif
  112.